Repository navigation
feat: add AWS Lambda Web Functions support - #103
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adapt the read-only smoke suite to the documented AWS CLI 2.38.x lambda-web response shapes without weakening any mandatory acceptance check: - revision identity now comes from get-web-function-endpoint (RevisionWeights[].RevisionId, endpoint State) corroborated by list-web-function-revisions; get-web-function no longer exposes a revision. - resource-policy lookups use get-resource-policy --resource-arn with the web-function ARN derived from the endpoint ARN. - capture_revision is errexit-safe on bash 3.2 so a missing API path reports BLOCKED instead of aborting the run. - stub and regression harness extended to the new shapes (smoke 44/44, lifecycle 61/61); missing/malformed responses stay BLOCKED, never PASS.
…stic - Correct the owned-bucket SSE-KMS/DSSE error messages to reference lambda.amazonaws.com (the principal whose key policy must allow kms:Decrypt), not the function execution role - Document that service-created default log groups outlive the stack (T7c teardown observation) and how to clean them up in sandboxes - Pin the corrected wording in the Web Function construct tests
- Add cdkc-18e.17 (P1): Sharedale consumer validation and stable release gate, tracking Sharedale milestone 6 as an external dependency. - Redact real AWS account, IAM user, sandbox id, and CloudFront distribution identifiers from cdkc-18e.13/cdkc-18e.14 evidence; preserve all AWS acceptance results and verification detail.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00dc8f8835
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (homeRegion is not null | ||
| && !Token.IsUnresolved(homeRegion) | ||
| && resolved.All(region => string.Equals(region, homeRegion, StringComparison.Ordinal))) |
There was a problem hiding this comment.
Defer region validation when non-home regions are unresolved
When the function's stack has an explicit region, configuring a MultiRegion or PerRegion endpoint with regions supplied through CloudFormation tokens (for example, Fn.ImportValue) throws during construction. Tokens are filtered out of resolved, so resolved.All(...) returns true for an empty list, or for a list containing only the literal home region—even though an unresolved entry may resolve to a valid non-home region. Reject this configuration only when all supplied regions are literal and demonstrably home-region-only; otherwise defer the check to deployment. The existing ValidateRegions_SkipsTokens test misses this path because it does not supply homeRegion, whereas the endpoint constructor always supplies the stack's region.
Useful? React with 👍 / 👎.
…d Regions Addresses Codex review on PR #103 (P2). WebFunctionValidation.ValidateRegions rejected a MultiRegion/PerRegion endpoint whose Regions were all unresolved CloudFormation tokens whenever the stack had a literal region: resolved was empty, and resolved.All(...) returns true for an empty sequence. This contradicted the module's contract that unresolved tokens are skipped rather than rejected, and blocked token-supplied non-home Regions. The home-Region-only check now applies only when every supplied Region is literal (resolved.Count == regions.Count); otherwise validation is deferred to deployment. Adds tests covering all-token and mixed token/literal Region lists. Also marks the props-builder _runtime field readonly (it is never reassigned).
|
@codex review Addressed the P2 finding on Please re-review this change specifically and check for regressions introduced by it. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Behaviour-preserving cleanups flagged by the GitHub code-quality review: - ValidateTimeout: test whole-second timeouts with decimal modulo instead of double comparison. - ValidateEntryPoint: drop the redundant 'entryPoint is null' constant check and rely on 'string.IsNullOrEmpty' (keeps nullable flow without CS8602). - WebFunctionConstructAssertions: use OfType<T>() instead of an implicit filter in a foreach. - Use Path.Join instead of Path.Combine in the golden-template harness and the ASP.NET Core / Blazor samples where a later argument could in principle be rooted. Build remains 0 warnings / 0 errors; 537/537 net8.0 tests pass.
|
@codex review Follow-up on the earlier P2 finding (ValidateRegions multi-Region home-Region check). The fix landed in a2eb9ff and is in the current head; the original comment was posted against the pre-fix commit 00dc8f8, so please re-review the current head. Current head 9413fe5 includes:
Please confirm the region validation is now correct and check for regressions in these changes. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Adds AWS Lambda Web Function constructs to
LayeredCraft.Cdk.Constructs, letting consumers deploy an ordinary HTTP server (Next.js, ASP.NET Core, Blazor Static SSR) from a zip in a versioned S3 bucket behind an AWS-managed HTTPS endpoint. Implements the approved design (revision 4,docs/designs/lambda-web-functions-integration.md) tracked by #98. The change is additive: no existing construct (Lambda Function, Static Site, DynamoDB Table, Cognito) is modified and their synthesized templates are unchanged.Changes
New public APIs
WebFunctionConstruct— owns one Web Function: function, revision, default endpoint, optional execution role, optional log group, and the function's single resource-based policy.AddEndpointadds additional endpoints; reserved child ids are rejected.WebFunctionEndpointConstruct(IWebFunctionEndpoint : IResourceWithPolicyV2) — an individual endpoint exposingEndpointName,EndpointArn,DomainName,Url,AuthType,EndpointType, plusGrantInvoke(identity- or resource-policy based),GrantCloudFrontInvoke,AddToResourcePolicy, andFromEndpointAttributesfor imports.WebFunctionOrigin— returns a CloudFrontIOriginwith origin access control (OAC) and the required resource-policy statement forIamAuthendpoints.WebFunctionConstructProps,WebFunctionCode/WebFunctionCodeFromBucketOptions/WebFunctionCodeBucketPolicy,WebFunctionRuntime,WebFunctionLogs,WebFunctionEndpointOptions/IWebFunctionEndpointOptions,WebFunctionEndpointAttributes,WebFunctionEndpointType,WebFunctionAuthType,WebFunctionCallerPolicy/WebFunctionInvokeGrantOptions,WebFunctionOriginProps/WebFunctionOriginWithOacProps/WebFunctionOriginPermissions.CloudFront OAC integration
WebFunctionOriginwires an origin access control together with the matching resource-policy statement on the Web Function endpoint, for same-stack distributions. Adding/removing a second distribution adds/removes a scoped statement (verified live).IAM / resource-policy security model
lambda:InvokeWebFunctionEndpointper endpoint.GrantInvokewrites an identity policy only when the caller account can be established; otherwise it fails closed. Service, wildcard, account, and condition-wrapped principals are rejected.WebFunctionCallerPolicydistinguishesAutomaticvsExternallyManagedgrants; immutable imported roles receive resource-policy-only grants.Minimum AWS CDK version
Amazon.CDK.Libfloor raised to 2.274.0 (required for the OAC signing enums). Consumers below the floor receive an automatic NuGet resolution upgrade.Workload support
Next.js, ASP.NET Core shims, and Blazor Static SSR deploy through the same public API; differences live only in the artifact and configuration. There are no workload-specific constructs or helpers.
Validation
dotnet build -c Release— 0 warnings / 0 errors acrossnet8.0–net11.0.mkdocs build --strictpasses.Documented limitations
WebFunctionCode.FromAssetis not available in this release — upload to a versioned bucket first.F3006default-rule validation warnings for the newAWS::Lambda::WebFunction*resource types (warnings by default).WebFunctionLogs.ServiceDefault()the Lambda service creates a log group that is not stack-owned and survives CloudFormation teardown.Intentional deferrals
KmsKeyArn) — deferred; S3 artifact encryption (SSE-S3 / SSE-KMS on the code bucket) is supported.AllViewerpolicy warning) closed won't-implement — not feasible with public CDK APIs.Related
cdkc-18e).cdkc-18e.17— Sharedale consumer validation and stable release (external dependency: Sharedale milestone 6). This gate remains open until the stable v2.6.0 release is authorized.Notes for Reviewers
WebFunctionConstructIAM classification relies partly on CDK/jsii principal materialization inAmazon.CDK.Lib2.274.0; theCdkUpgradeGuard_*security suite guards future CDK bumps.